import cv2
import numpy as np

img1 = cv2.imread('img.jpg')
img3 = cv2.imread('img3.jpg')

img3 = cv2.resize(img3, (100, 100))
img1 = cv2.resize(img1, (400, 300))  # 统一图片大小

img1[50:150,50:150]=img3
#img1[50:150,50:150]=[255, 0, 0]

image_1=img1
image_3 =cv2.imread('huzi.png',cv2.IMREAD_UNCHANGED)
image_3= cv2.resize(image_3, (100, 100))
ones = np.ones((image_1.shape[0], image_1.shape[1]))*255
image_1 = np.dstack([image_1, ones])
image_1[150:250, 150:250] = image_3
# alpha_image_3 = image_3[:, :, 3] / 255.0
# alpha_image = 1 -alpha_image_3
# for c in range(0, 3):
#     image_1[150:250, 150:250, c] = ((alpha_image*image_1[150:250,      150:250, c]) + (alpha_image_3*image_3[:, :, c]))

cv2.imshow('input', image_1)
cv2.waitKey(0)

cv2.destroyAllWindows()